package com.ctgu.controller;


import com.ctgu.common.ResponseResult;
import com.ctgu.model.entity.Position;
import com.ctgu.service.IPositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yiMa
 * @since 2023-07-05
 */
@RestController
@RequestMapping("/position")
public class PositionController {

    @Autowired
    private IPositionService positionService;

    @GetMapping("/list")
    @PreAuthorize("@AYM.hasAuthority('position:info:list')")
    public ResponseResult getList(Integer depId){
        return positionService.getList(depId);
    }

    @PostMapping("/updatePosition")
    @PreAuthorize("@AYM.hasAuthority('employee:position:update')")
    public ResponseResult updatePosition(@RequestBody Integer[] eIds, Integer posId){
        return positionService.updatePosition(eIds,posId);
    }
    @PostMapping("/add")
    @PreAuthorize("@AYM.hasAuthority('position:one:add')")
    public ResponseResult add(@RequestBody Position position){
        return positionService.add(position);
    }
    @DeleteMapping("/delete")
    @PreAuthorize("@AYM.hasAuthority('position:one:delete')")
    public ResponseResult delete(Integer id){
        return positionService.delete(id);
    }

    @PutMapping("/update")
    @PreAuthorize("@AYM.hasAuthority('position:one:update')")
    public ResponseResult updateInfo(Integer id,String name){
        return positionService.updateInfo(id,name);
    }
}

